package cn.kgc.novel.service.impl;

import cn.kgc.novel.mapper.BooksMapper;
import cn.kgc.novel.pojo.Bookcontext;
import cn.kgc.novel.pojo.Books;
import cn.kgc.novel.pojo.Bookshelf;
import cn.kgc.novel.service.BooksService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
//杨将
@Service
public class BooksServiceImpl implements BooksService {
    @Resource
    private BooksMapper booksMapper;
    //重写根据角色id来查找所写的小说内容
    @Override
    public List<Books> findshow(String bookname) {
        List<Books> findshows = booksMapper.findshows(bookname);
        return findshows;
    }
    @Override
    public List<Books> thecharts(String category, String sex) {
        if("全部".equals(category)){
            category = null;
        }
        return booksMapper.thecharts(category, sex);
    }
    //拿最近更新时间
    @Override
    public List<Books> nashijian(String category,String sex) {
        return booksMapper.nashijian(category,sex);
    }
    //模糊查更据小说名字查
    @Override
    public List<Books> vaguevague(String bookname,String renewaltime) {
        return booksMapper.vaguevague(bookname,renewaltime);
    }
    @Override
    //更据小说名查小说最近更新时间
    public Books updatetime(String booknames,String typesof){
        return booksMapper.updatetime(booknames,typesof);
    }

    @Override
    public List<Books> vagueshow(String booknames, String renewaltime, String booknum, String status) {
        return booksMapper.vagueshow(booknames,renewaltime,booknum,status);
    }
    //查看书架的书籍
    @Override
    public List<Books> getShelf(List<Bookshelf> bookshelves,String status) {
        List<Books> booksList=booksMapper.findShelf(bookshelves, status);
        return booksList;
    }
    @Override
    public void addBooks(Books books) {
        booksMapper.addBooks(books);
    }

    @Override
    public List<Books> unpublished(Integer authorid) {
        return booksMapper.unpublished(authorid);
    }

    @Override
    public List<Bookcontext> findtitles(int[] titleids, String[] bids) {
        return booksMapper.findtitles(titleids,bids);
    }

    //新加
//查询子数和人气的2个总合
    @Override
    public List<Books> popularity(Integer authorid) {
        return booksMapper.popularity(authorid);
    }

    @Override
    public int wanjie(Integer bid, Integer uid,String status) {
        return booksMapper.wanjie(bid,uid,status);
    }

    //下架书籍
    @Override
    public void deleteBook(Integer bid) {
        booksMapper.deleteBook(bid);
    }
    //通过作者或小说名称来查找小说
    @Override
    public List<Books> selectBooks(String author, String bookname) {
        return booksMapper.selectBooks(author,bookname);
    }

    //修改书籍状态
    @Override
    public void setStatus(Integer bid) {
        booksMapper.updateStatus(bid);
    }


    //未整合过的方法  删除作者所写的小说
    @Override
    public void deletenovel(int authorid, String bookname) {
        booksMapper.deletenovel(authorid,bookname);
    }
    //更据小说名查小说对应的id
    @Override
    public Integer selectid(String bookname) {
        return booksMapper.selectid(bookname);
    }

    @Override
    public List<String> zhinengfind(String bookname) {

        return booksMapper.zhinengfind(bookname);
    }

    //2023-11-22 通过类型id查找给类型的所有小说
    @Override
    public List<Books> findBookByTypeId(Integer typeid) {
        return booksMapper.findBookByTypeId(typeid);
    }
    //2023-11-22 通过书籍id查找书籍信息和作者信息
    @Override
    public Books findUsersByBid(Integer bid) {
        return booksMapper.findUsersByBid(bid);
    }

}
